#[allow(dead_code)]
fn get_admin(id: usize, state: &State<MySqlDriver>) -> u8 {  // 0, 1, 2
    let pool: Pool = Pool::new(state.driver.as_str()).unwrap();
    let mut conn: PooledConn = pool.get_conn().unwrap();
    let sql: String = format!("SELECT `is_admin` FROM `user` WHERE `id` = {}", id);
    let row_op: Option<Row> = conn.query_first(sql).unwrap();
    let row: Row;
    if let Some(r) = row_op {
        row = r;
    } else {
        return 0;
    }
    let is_admin: u8 = from_row(row);
    return is_admin;
}

#[allow(dead_code)]
fn is_superadmin(id: usize, state: &State<MySqlDriver>) -> bool {
    let pool: Pool = Pool::new(state.driver.as_str()).unwrap();
    let mut conn: PooledConn = pool.get_conn().unwrap();
    let sql: String = format!("SELECT `is_superadmin` FROM `user` WHERE `id` = {}", id);
    let row_op: Option<Row> = conn.query_first(sql.clone()).unwrap();
    let row: Row;
    if let Some(r) = row_op {
        row = r;
    } else {
        return false;
    }
    let is_super: u8 = from_row(row);
    if is_super == 0 {
        return false;
    } else {
        return true;
    }
}

